package top.infopub.mgr.sys.web;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.infopub.dubbo.vo.mgc.MsgSenderRoleVo;
import top.infopub.dubbo.ws.mgc.MsgSenderService;
import top.infopub.generic.GenericController;
import top.infopub.tdp.sys.service.CodeGeneratorConfigService;


/**
 * Awoke系统主入口
 * @author Awoke
 * @version 2018年10月15日
 * @see AwokeTestController
 * @since
 */
@Controller
@RequestMapping("/awoke")
public class AwokeTestController extends GenericController {

    @Autowired
    private MsgSenderService msgSenderService;

    @Autowired
    private CodeGeneratorConfigService codeGeneratorConfigService;

    /**
     * test
     * @return
     */
    @RequestMapping(value = "/test/genCode")
    @ResponseBody
    public String testGenCode(HttpServletRequest request, HttpServletResponse response) {
        System.out.println(codeGeneratorConfigService.generatorCode("Test"));
        return null;
    }

    /**
     * test
     * @return
     */
    @RequestMapping(value = "/test/email")
    @ResponseBody
    public String testEmail(HttpServletRequest request, HttpServletResponse response) {

        MsgSenderRoleVo vo = new MsgSenderRoleVo();
        vo.setPurviewCode("BHT_ERROR_WARN");
        vo.setTemplateMainCode("BHT_ERROR_WARN");
        Map<String, Object> ctxMap = new HashMap<>();
        ctxMap.put("bizName", "测试邮件");
        ctxMap.put("remark", "测试邮件接收，来自bht");
        vo.setContentParam(ctxMap);
        // 发送告警
        msgSenderService.sendRole(vo);

        return null;
    }

}
